From c90c5959d4eb5559d65658e8edc33be01c50bfc1 Mon Sep 17 00:00:00 2001 From: "awilliam@xenbuild.aw" Date: Tue, 26 Sep 2006 16:15:45 -0600 Subject: [PATCH] [IA64] Complete fpswa handler retry mechanism When handling fpswa fault, Xen needs to fetch opcode, it may fail. This patch finishes retry mechanism. Signed-off-by: Anthony Xu --- xen/arch/ia64/vmx/vmx_process.c | 21 ++++++++++++++++----- xen/arch/ia64/vmx/vmx_vcpu.c | 15 +++++++++++++++ xen/include/asm-ia64/ia64_int.h | 4 +++- xen/include/asm-ia64/vmx_vcpu.h | 1 + 4 files changed, 35 insertions(+), 6 deletions(-) diff --git a/xen/arch/ia64/vmx/vmx_process.c b/xen/arch/ia64/vmx/vmx_process.c index 7867fd3993..ad37920dc2 100644 --- a/xen/arch/ia64/vmx/vmx_process.c +++ b/xen/arch/ia64/vmx/vmx_process.c @@ -81,6 +81,7 @@ static UINT64 vec2off[68] = {0x0,0x400,0x800,0xc00,0x1000, 0x1400,0x1800, void vmx_reflect_interruption(UINT64 ifa,UINT64 isr,UINT64 iim, UINT64 vector,REGS *regs) { + UINT64 status; VCPU *vcpu = current; UINT64 vpsr = VCPU(vcpu, vpsr); vector=vec2off[vector]; @@ -89,13 +90,23 @@ void vmx_reflect_interruption(UINT64 ifa,UINT64 isr,UINT64 iim, } else{ // handle fpswa emulation // fp fault - if(vector == IA64_FP_FAULT_VECTOR && !handle_fpu_swa(1, regs, isr)){ - vmx_vcpu_increment_iip(vcpu); - return; + if (vector == IA64_FP_FAULT_VECTOR) { + status = handle_fpu_swa(1, regs, isr); + if (!status) { + vmx_vcpu_increment_iip(vcpu); + return; + } else if (IA64_RETRY == status) + return; } //fp trap - else if(vector == IA64_FP_TRAP_VECTOR && !handle_fpu_swa(0, regs, isr)){ - return; + else if (vector == IA64_FP_TRAP_VECTOR) { + status = handle_fpu_swa(0, regs, isr); + if (!status) + return; + else if (IA64_RETRY == status) { + vmx_vcpu_decrement_iip(vcpu); + return; + } } } VCPU(vcpu,isr)=isr; diff --git a/xen/arch/ia64/vmx/vmx_vcpu.c b/xen/arch/ia64/vmx/vmx_vcpu.c index e6824d3ec9..3d9c65a7f0 100644 --- a/xen/arch/ia64/vmx/vmx_vcpu.c +++ b/xen/arch/ia64/vmx/vmx_vcpu.c @@ -172,6 +172,21 @@ IA64FAULT vmx_vcpu_increment_iip(VCPU *vcpu) } +IA64FAULT vmx_vcpu_decrement_iip(VCPU *vcpu) +{ + REGS *regs = vcpu_regs(vcpu); + IA64_PSR *ipsr = (IA64_PSR *)®s->cr_ipsr; + + if (ipsr->ri == 0) { + ipsr->ri = 2; + regs->cr_iip -= 16; + } else { + ipsr->ri--; + } + return (IA64_NO_FAULT); +} + + IA64FAULT vmx_vcpu_cover(VCPU *vcpu) { REGS *regs = vcpu_regs(vcpu); diff --git a/xen/include/asm-ia64/ia64_int.h b/xen/include/asm-ia64/ia64_int.h index 0bef5b4a1b..711078104b 100644 --- a/xen/include/asm-ia64/ia64_int.h +++ b/xen/include/asm-ia64/ia64_int.h @@ -36,7 +36,9 @@ #define IA64_NO_FAULT 0x0000 #define IA64_FAULT 0x0001 #define IA64_RFI_IN_PROGRESS 0x0002 -#define IA64_RETRY 0x0003 +// To avoid conflicting with return value of handle_fpu_swa() +// set IA64_RETRY to -0x000f +#define IA64_RETRY (-0x000f) #define IA64_FORCED_IFA 0x0004 #define IA64_USE_TLB 0x0005 #define IA64_ILLOP_FAULT (IA64_GENEX_VECTOR | 0x00) diff --git a/xen/include/asm-ia64/vmx_vcpu.h b/xen/include/asm-ia64/vmx_vcpu.h index a82e31fb7f..0a82cad583 100644 --- a/xen/include/asm-ia64/vmx_vcpu.h +++ b/xen/include/asm-ia64/vmx_vcpu.h @@ -114,6 +114,7 @@ extern void memwrite_v(VCPU *vcpu, thash_data_t *vtlb, u64 *src, u64 *dest, size extern void memwrite_p(VCPU *vcpu, u64 *src, u64 *dest, size_t s); extern void vcpu_load_kernel_regs(VCPU *vcpu); extern IA64FAULT vmx_vcpu_increment_iip(VCPU *vcpu); +extern IA64FAULT vmx_vcpu_decrement_iip(VCPU *vcpu); extern void vmx_switch_rr7(unsigned long ,shared_info_t*,void *,void *,void *); extern void dtlb_fault (VCPU *vcpu, u64 vadr); -- 2.30.2